package com.z6pin.user.z6pinuser.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.z6pin.user.z6pinuser.domain.Person;
import com.z6pin.user.z6pinuser.domain.UserCoin;

@Service
public class UserCoinHystrixService {

	@Autowired
	UserCoinService userCoinService; 

	@HystrixCommand(fallbackMethod = "fallbackSaveCoin") //1
	public int saveUserCoin(UserCoin userCoin) {
		
		return userCoinService.saveCoin(userCoin);
	}
	
	public int fallbackSaveCoin(UserCoin userCoin){ 
		System.out.println("SaveCoin服务调用失败----------");
		return -1;
	}
	
	@HystrixCommand(fallbackMethod = "fallbackCanInsert") //1
	public String canInsert() {
		
		return userCoinService.canInsert();
	}
	
	public String fallbackCanInsert(){ 
		System.out.println("调用是否可插入服务失败----------");
		return "failed";
	}
}
